const RandomKey = '5d9187594aea20fa5fb6e01690ed99d1';
const websiteNameKey = '5s93k7s94aea21fa2fb3e02690ed9fd1';

export function randomKey(length) {
    if (!length || isNaN(parseInt(length))) {
        length = 16
    }
    let chars = ['2', '3', '4', '5', '6', '7', '8', '9',
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    let nums = ""
    for (let i = 0; i < length; i++) {//这里是几位就要在这里不改变
        let id = parseInt((Math.random() * 54) + '');
        nums += chars[id]
    }
    console.log(nums)
    return nums
}

export function setRandomKey() {
    return localStorage.setItem(RandomKey, randomKey())
}

export function getRandomKey() {
    return localStorage.getItem(RandomKey) || null
}

export function removeRandomKey() {
    return localStorage.removeItem(RandomKey)
}

export function setWebsiteName(name) {
    return localStorage.setItem(websiteNameKey, name)
}

export function getWebsiteName() {
    return localStorage.getItem(websiteNameKey)
}